package com.falcon.system.controller;

import com.falcon.core.controller.IBaseController;
import com.falcon.core.domain.BasePager;
import com.falcon.core.domain.BaseResponse;
import com.falcon.system.domain.po.SystemLogPO;
import com.falcon.system.domain.request.SystemLogQuery;
import com.falcon.system.service.ISystemLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/system/systemLog")
@Tag(name = "SystemLogController", description = "系统日志-接口")
public class SystemLogController implements IBaseController {

    @Autowired
    private ISystemLogService systemService;

    @Operation(summary = "删除")
    @DeleteMapping("/delete/{id}")
    public BaseResponse<Boolean> deleteById(@PathVariable Long id) {

        Boolean success =  this.systemService.deleteById(id);

        return BaseResponse.success(success);
    }

    @Operation(summary = "批量删除")
    @PostMapping("/batchDelete")
    public BaseResponse<Integer> batchDelete(@RequestBody List<Long> ids) {

        Integer num =  this.systemService.batchDelete(ids);

        return BaseResponse.success(num);
    }

    @Operation(summary = "查询基本信息")
    @GetMapping("/{id}")
    public BaseResponse<SystemLogPO> detail(@PathVariable Long id) {

        SystemLogPO systemDo =  this.systemService.queryById(id);

        return BaseResponse.success(systemDo);
    }

    @Operation(summary = "列表查询")
    @PostMapping("/list")
    public BaseResponse<List<SystemLogPO>> list(@RequestBody SystemLogQuery request) {

        List<SystemLogPO> list =  this.systemService.queryList(request);

        return BaseResponse.success(list);
    }

    @Operation(summary = "分页查询")
    @PostMapping("/pager")
    public BaseResponse<BasePager<SystemLogPO>> pager(@RequestBody SystemLogQuery request) {

        BasePager<SystemLogPO> pager =  this.systemService.queryPager(request);

        return BaseResponse.success(pager);
    }

}

